package com.atguigu.lease.web.admin.service.impl;

import com.atguigu.lease.model.enums.BaseStatus;
import com.atguigu.lease.web.admin.vo.user.UserInfoQueryVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.lease.model.entity.UserInfo;
import com.atguigu.lease.web.admin.service.UserInfoService;
import com.atguigu.lease.web.admin.mapper.UserInfoMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
* @author liubo
* @description 针对表【user_info(用户信息表)】的数据库操作Service实现
* @createDate 2023-07-24 15:48:00
*/
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
    implements UserInfoService{


    @Override
    public IPage<UserInfo> pageUserInfo(IPage<UserInfo> userInfoPage, UserInfoQueryVo queryVo) {
        BaseStatus status = queryVo.getStatus();
        String phone = queryVo.getPhone();
        QueryWrapper<UserInfo> userInfoQueryWrapper = new QueryWrapper<>();
        userInfoQueryWrapper.eq(status != null,"status",status);
        userInfoQueryWrapper.like(StringUtils.hasText(phone),"phone",phone);  //StringUtils.hasText(phone)表示phone不能为空
        IPage<UserInfo> userInfoIPageResult = baseMapper.selectPage(userInfoPage,userInfoQueryWrapper);
        return userInfoIPageResult;
    }
}




